package cm.day13.Test2;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        //创建一个Server
        Socket socket = new Socket("127.0.0.1", 10086);
        //获取网络输出流
        OutputStream ops = socket.getOutputStream();
        //转化为高效流
        DataOutputStream dos = new DataOutputStream(ops);
        //写出数据
        dos.writeUTF("小白真帅");
        //结束语句
        socket.shutdownOutput();
        //3.接收服务端回写的数据
        InputStream is=socket.getInputStream();
        DataInputStream dis=new DataInputStream(is);
        String s = dis.readUTF();
        System.out.println(s);
        //释放资源
        socket.close();
    }
}
